//Stephen Kirksharian
//Robert Harkreader
//CPSC 321
//DUE 4/27/08

// Texas A&M University          //
// cpsc321 Computer Architecture //
// $Id: signextend.v,v 1.1 2001/11/07 19:25:23 miket Exp miket $ //
// A insize->outsize sign extender //

`define USIGN 16'b0000000000000000
module SIGN_EXTEND(in, out, ctr);
   parameter INSIZE = 16, OUTSIZE = 32;
   input ctr;
   input [INSIZE-1:0] in;
   output [OUTSIZE-1:0] out;
   reg [OUTSIZE-1:0]out;

always @(ctr) begin
   if(ctr==1) begin
      assign 	 out = {{ OUTSIZE-INSIZE {in[INSIZE-1]}}, in};
      $display("in ctr==1");
   end else begin
      assign     out = {`USIGN,in};
	   
   end
end
endmodule // SIGN_EXTEND
  
